package unknow;

import java.util.ArrayList;
import java.util.List;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import entity.User;
import org.junit.Test;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

/**
 * @author LiDong
 * @version 1.0.0
 * @createTime 5/31/2022 8:20 AM
 */
public class JsonTest {

    private static final Logger logger = LoggerFactory.getLogger(JsonTest.class);

    @Test
    public void test1() {
        Object test = JSON.parse("test");
        logger.info(String.valueOf(test));
    }

    @Test
    public void test2() {
        List<User> list = new ArrayList<>();
        for (int i = 0; i < 5; i++) {
            User user = new User();
            user.setId(i);
            list.add(user);
        }
        JSONArray users = JSON.parseArray(JSON.toJSONString(list));
        logger.info(String.valueOf(users));
    }

}
